package com.taotao.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.common.pojo.EasyUIDataGridResult;
import com.taotao.common.pojo.TaotaoResult;
import com.taotao.pojo.TbItem;
import com.taotao.service.ItemService;

@Controller
public class ItemController {
	
	@Autowired
	private ItemService itemService;

	@RequestMapping("item/{itemId}")
	@ResponseBody
	public TbItem getItemById(@PathVariable long itemId){
		TbItem item =itemService.getItemById(itemId);
		return item;
	}

	@RequestMapping("/item/list")
	@ResponseBody
	public EasyUIDataGridResult showItemlist(int page,int rows){
		EasyUIDataGridResult result=itemService.itemList(page, rows);
		return result;
		
	}
	@RequestMapping("/item/save")
	@ResponseBody
	public TaotaoResult addItem(TbItem tbItem,String itemDesc){
		TaotaoResult result = itemService.addItem(tbItem, itemDesc);
		return result;
	}
	
	
}
